package com.whfc.ms.api.sys.controller;

import com.whfc.common.base.BaseController;
import com.whfc.common.result.PageData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.fuum.dto.WxUserDTO;
import com.whfc.fuum.entity.SysUser;
import com.whfc.fuum.service.WxUserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/7/16 11:05
 */
@RequiresPermissions(value = "sys/wxUser")
@RestController
@RequestMapping("/ms/api/user/wxmp")
public class SysWxUserController extends BaseController {

    @DubboReference(interfaceClass = WxUserService.class, version = "1.0.0")
    private WxUserService wxUserService;

    /**
     * 微信用户列表
     *
     * @param sysUser
     * @param pageNum
     * @param pageSize
     * @param keyword
     * @param appType
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("list")
    public Result wxmpUserList(@SessionAttribute(SessionAttr.MS_USER) SysUser sysUser,
                               @RequestParam("pageNum") Integer pageNum,
                               @RequestParam("pageSize") Integer pageSize,
                               @RequestParam(value = "keyword", required = false) String keyword,
                               @RequestParam(value = "appType", required = false) Integer appType,
                               @RequestParam(value = "startDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
                               @RequestParam(value = "endDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        logger.info("微信用户列表,loginer:{},pageNum:{},pageSize:{},keyword:{},appType:{},startDate:{},endDate:{}",
                sysUser.getUsername(), pageNum, pageSize, keyword, appType, startDate, endDate);
        PageData<WxUserDTO> pageData = wxUserService.wxmpUserList(pageNum, pageSize, keyword, appType, startDate, endDate);
        return ResultUtil.success(pageData);
    }

}
